package demo_JUC.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class demo001 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyThread myThread = new MyThread();
        FutureTask futureTask1 = new FutureTask(myThread); // 配饰类
        FutureTask futureTask2 = new FutureTask(myThread); // 配饰类
        new Thread(futureTask1, "A").start();
        new Thread(futureTask2, "B").start();
        Integer ret1 = (Integer) futureTask1.get();
        System.out.println(ret1);
        Integer ret2 = (Integer) futureTask2.get();
        System.out.println(ret2);
    }
    static class MyThread implements Callable<Integer>{
        @Override
        public Integer call() throws Exception {
            System.out.println(Thread.currentThread().getName() + "---call");
            return 1024;
        }
    }
}
